#!/bin/bash

#----------------------------------------------------
# File: stdout.sh
# Contents: print vs echo
# Date: 19-03-20
#----------------------------------------------------

#---------------------------------------------------------------------------------------------------
#####################  输出格式  ####################
# echo 换行输出
# printf 一行输出
#
#---------------------------------------------------------------------------------------------------

echo "echo输出格式:"
echo "======================"
echo "123"
echo "======================"
echo

echo "printf输出格式:"
printf "======================"
printf "123"
printf "======================"
printf "\n"
echo

#---------------------------------------------------------------------------------------------------
###################  echo特色  #####################
# echo -e "\033[字体背景颜色; 字体颜色m字符串\033[0m"
# echo -e "\033[41; 36m字符串\033[0m"
#
# 字体色NN  0:默认, 31:红色, 32:绿色, 33:黄色, 34:蓝色, 35:紫色 36:天蓝 37:白色
# 背景色NN  0:默认, 41:红色, 42:绿色, 43:黄色, 34:蓝色, 45:紫色 46:天蓝 47:白色
#
# 其他控制选项:
# \033[0m 关闭所有属性
# \033[1m 设置高亮度
# \033[4m 下划线
# \033[5m 闪烁
# \033[7m 反显
# \033[8m 消隐
# \033[2J 清屏
#
#---------------------------------------------------------------------------------------------------


echo "背景色控制:"
echo -e "\033[1;31mRed Background \033[0m"
echo -e "\e[31mRed Background \e[0m"
echo -e "\e[41mRed Background\e[0m"
echo

# echo -n "..." 取消换行输出
echo "取消换行"
echo -n "1"
echo -n "2"
echo
echo

#---------------------------------------------------------------------------------------------------
#######################  printf特色  ##########################
# printf 格式化输出
# %d, %d, %d
#
#---------------------------------------------------------------------------------------------------


echo "printf特色:"
printf "%4s : %-10s\n" "Name" "Address"
printf "%4s : %-10s\n" "Tom" "HeiBei Province"
printf "%4s : %-10s\n" "Jack" "陕西省西安市蓝田县张家口乡"
